package com.jiazhong.cloud.example.student.school.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiazhong.cloud.example.student.commons.bean.School;
import com.jiazhong.cloud.example.student.commons.mapper.SchoolMapper;
import com.jiazhong.cloud.example.student.commons.util.JsonResult;
import com.jiazhong.cloud.example.student.commons.util.ResultTool;
import com.jiazhong.cloud.example.student.school.service.SchoolService;
import jakarta.annotation.Resource;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, School> implements SchoolService {

    @Resource
    private SchoolMapper schoolMapper;

    @Override
    public JsonResult saveSchool(School school) {
        save(school);
        return ResultTool.success("success");
    }

    @Cacheable(cacheNames = "findSchoolById")
    public JsonResult findSchoolById(String id) {
        return ResultTool.success(schoolMapper.selectById(id));
    }
}
